package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.DevicePageQueryDto;
import com.zzyl.entity.Device;
import com.zzyl.entity.DeviceData;
import com.zzyl.vo.DeviceDataGraphVo;
import com.zzyl.vo.DeviceDataVo;
import com.zzyl.vo.DeviceVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Mapper
public interface DeviceMapper {
    //查找设备
    @Select("select count(*) from device where device_name = #{deviceName}")
    int countByDeviceName(String deviceName);

    //新增设备
    void insert(Device device);

    //分页查询设备
    Page<DeviceVo> selectByPage(DevicePageQueryDto devicePageQueryDto);

    //查询设备详情
    DeviceVo queryDeviceDetail(String iotId);//根据产品唯一标识iotId查询设备详情

    //修改设备备注名称
    void updateDevice(Device device);

    //删除设备
    void deleteById(String iotId);

    //动态插入数据库
    void batchInsert(List<DeviceData> deviceData1);



    //按天统计查询指标数据
//    List<DeviceDataGraphVo> queryDeviceDataListByDay(String iotId, String functionId, LocalDateTime startDateTime, LocalDateTime endDateTime);

    List<DeviceDataGraphVo> queryDeviceDataListByDay(@Param("iotId") String iotId, @Param("functionId") String functionId,@Param("startDateTime") LocalDateTime startDateTime,@Param("endDateTime") LocalDateTime endDateTime);


    //按周统计查询指标数据
    List<DeviceDataGraphVo> queryDeviceDataListByWeek(String iotId, String functionId, LocalDateTime startDateTime, LocalDateTime endDateTime);

    List<Long> selectNursingIdsByIotIdWithElder(String iotId);

    List<Long> selectNursingIdsByIotIdWithBed(String iotId);
}
